package hu;

import java.util.*;

public class TLV {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String tag = sc.nextLine();
        String[] input = sc.nextLine().split(" ");
        for (int i = 0; i < input.length; i++) {
            int t = i;
            String n1 = input[++i];
            String n2 = input[++i];
            int n = Integer.parseInt(n2 + n1, 16);
            if(!tag.equals(input[t])){
                for (int j = 0; j < n; j++) {
                    i++;
                }
            }
            else {
                for (int j = 0; j < n; j++) {
                    i++;
                    System.out.print(input[i] + " ");
                }
                break;
            }
        }
    }
}
/*
33
32 01 00 AE 90 02 00 01 02 30 03 00 AB 32 31 31 02 00 32 33 33 01 00 CC

 */